package middleware

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"os"
)

func TokenCheck01(c *gin.Context) {
	accessToken := c.GetHeader("access_token")
	expectedToken := os.Getenv("ACCESS_TOKEN")
	if accessToken != expectedToken {
		c.JSON(http.StatusUnauthorized, gin.H{
			"message": "Token validation failed",
		})
		c.Abort()
		return
	}
	c.Set("user_name", "ni")
	c.Set("user_id", "100")
	c.Next()
}
